from appium import webdriver
import time
from appium.webdriver.common.appiumby import By

# 连接配置信息
des = {
    "platformName": "Android",
    "platformVersion": "7.1.2",
    "deviceName": "emulator-5554",
    "appPackage": "com.android.settings",
    "appActivity": ".Settings"
}

# 实例化驱动对象
driver = webdriver.Remote("http://127.0.0.1:4723/wd/hub", des)
#
# # 点击-更多
# driver.find_element(By.XPATH, "//*[@text='更多']").click()
# time.sleep(2)
# # 点击-移动网络
# driver.find_element(By.XPATH, "//*[@text='移动网络']").click()
# time.sleep(2)
# # 返回
# driver.back()
# time.sleep(2)
# # 返回
# driver.back()
# time.sleep(2)

# # 设置网络模式
# driver.set_network_connection(1)

# time.sleep(2)
# # 截图
# driver.get_screenshot_as_file(".\my_pic.png")

# 获取屏幕宽高
print(driver.get_window_size())

driver.quit()
